import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';

extension StringColor on String {
  Color get stringToColor {
    final buffer = StringBuffer();
    if (length == 6 || length == 7) buffer.write('ff');
    buffer.write(replaceFirst('#', ''));
    return Color(int.parse(buffer.toString(), radix: 16));
  }

  //  时间转时间戳
  int get intTimeWithString {
    int? value =   DateUtil.getDateMsByTimeStr(this);
    if(value!=null){
      String string = (value/1000).toString();
      return int.parse(string.split('.').first);
    }
    return 0;
  }
}